<template>
    <div class="wrapper">
            <h2>文本输入框组件</h2>
            <div class="shape">
                <h3>效果展示</h3>
                <div>
                    <Button theme="button" @click="setVisible">显示</Button>
                    <TextInput placeholder="请在此输入内容" v-model:inputContent="inputContent" 
                                v-model:visible="visible" :ok="fn1" :cancel="fn2">
                    </TextInput> 
                </div>
            </div>
            <div class="markdown-body">
                <pre><code>{{
`<TextInput placeholder="请在此输入内容" v-model:inputContent="inputContent" 
            v-model:visible="visible" :ok="fn1" :cancel="fn2">
</TextInput> `
                    }}</code></pre>
            </div>
            <div class="shape">
                <h3 @click="getCode">查看源码</h3>
                <main class="markdown-body" v-show="code">
    <pre><code>{{
`<template>
    <TextInput placeholder="请在此输入内容" v-model:inputContent="inputContent" 
        v-model:visible="visible" :ok="fn1" :cancel="fn2">
    </TextInput>
</template>
    
<script lang="ts">
import TextInput from "../lib/TextInput.vue"
import {ref} from 'vue'    
export default {
    components:{TextInput,Button},
    setup(){
        const inputContent = ref('')
        const visible = ref(false)
        const setVisible=()=>{
            visible.value=!visible.value
        }
        const fn1=()=>{
            console.log('this is fn1')
        }
        const fn2=()=>{
            console.log('this is fn2')
        }
        return {inputContent,visible,setVisible,fn1,fn2}
    }
}
</script>`
    }}</code></pre>
                </main>
            </div>
        </div> 
    </template>


<script lang="ts">
import TextInput from "../lib/TextInput.vue"
import Button from '../lib/Button.vue'
import {ref} from 'vue'    
export default {
    components:{TextInput,Button},
    setup(){
        const inputContent = ref('')
        const visible = ref(false)
        const setVisible=()=>{
            visible.value=!visible.value
        }
        const fn1=()=>{
            console.log('this is fn1')
        }
        const fn2=()=>{
            console.log('this is fn2')
        }
        const code=ref(false)
        const getCode=()=>{
                code.value=!code.value
        }
        return {inputContent,visible,setVisible,fn1,fn2,code,getCode}
    }
}
</script>

<style lang="scss" scoped>
.wrapper{
    max-width:800px;
    h2{
        padding-bottom: 30px;
        border-bottom: 1px solid rgb(212, 208, 208);
    }
    .shape{
        margin:30px 0px;
        >h3{
            margin-bottom: 10px;
        }
        >div{
            display: flex;
            padding: 50px;
            align-items: center;
            justify-content: center;
            border:1px solid rgb(212, 208, 208);
        }
    }
}
@media (max-width:500px) {
    .wrapper{
        width:380px;
    }       
}
</style>